// 引用网络请求中间件
import request from '../../utils/request.js';

const API_NAME = '/group'
/* 圈子 */

export default {
	/**
	@param{number}data 第一个参数是对象类型
	@returns 返回俩个参数的和
	*/
	/* 创建圈子 */
	createGroup(data) {
		return request({
			url: `${API_NAME}/groupApi/add`,
			method: 'POST',
			data
		})
	},
	/* 拉人建圈 wx */
	// http://192.168.3.5:8080/group/groupApi/add/users/wx?userId=1111&userName=1111
	pullPeopleGroup(userId, userName, userIds, latitude = 1, longitude = 1) {
		console.log(typeof(userName), "str");
		return request({
			url: `${API_NAME}/groupApi/add/users/wx?latitude=${latitude}&longitude=${longitude}&userId=${userId}&userName=我的名字`,
			method: 'POST',
			userIds
		})
	},
	/* 解散圈子 */
	/* eg: http://192.168.3.5:8080/group/groupApi/delete?ugroupId=111&userId=222 */
	dissolveGroup(ugroupId, userId) {
		return request({
			url: `${API_NAME}/groupApi/delete?ugroupId=${ugroupId}&userId=${userId}`,
			method: 'DELETE',
		})
	},
	/* 解散圈子返回圈组成员 */
	/* eg: http://192.168.3.5:8080/group/groupApi/dismissGroup?ugroupId=22&userId=33  */
	dissolveGroupReturnMember(ugroupId, userId) {
		return request({
			url: `${API_NAME}/groupApi/dismissGroup?ugroupId=${ugroupId}&userId=${userId}`,
			method: 'DELETE',
		})
	},
	/* 通过id查询圈子信息 */
	/**
	 * @param {Number} groupId
	 */
	findGroupInfoById(groupId) {
		return request({
			url: `${API_NAME}/groupApi/group?groupId=${groupId}`,
			method: 'GET',
		})
	},
	/* 修改圈子 */
	changeGroup(data) {
		return request({
			url: `${API_NAME}/groupApi/update`,
			method: 'PUT',
			data
		})
	},
	/* 附近的群聊 */
	nearbyGroup(current = 1, distance = 5, latitude = 10, longitude = 10, size = 5) {
		return request({
			url: `${API_NAME}/groupApi/nearbyGroup?current=${current}&distance=${distance}&latitude=${latitude}&longitude=${longitude}&size=${size}`,
			method: 'GET',
		})
	}
}
